package com.guigu.dealservice.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.guigu.dealservice.dto.EquipmentType;
import com.guigu.dealservice.dto.User;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * <p>
 * 求购信息表（存储买家发布的二手机械求购需求）
 * </p>
 *
 * @author ysp
 * @since 2025-10-10
 */
@TableName("purchase_demand")
public class PurchaseDemand implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 求购信息唯一标识
     */
    @TableId(value = "purchase_id", type = IdType.AUTO)
    private Long purchaseId;

    /**
     * 关联用户表user_id（求购信息发布者）
     */
    private Integer userId;

    /**
     * 关联设备类型表equipment_type的type_id（替代原equipment_type字符串字段）
     */
    private Long typeId;

    /**
     * 求购设备品牌（可选，如"优先三一"）
     */
    private String brand;

    /**
     * 求购设备型号（可选，如"SY215C"）
     */
    private String model;

    /**
     * 期望价格（单位：元，买家可接受的最高价格）
     */
    private BigDecimal expectedPrice;

    /**
     * 期望设备年份（可选，如"2018年以后"）
     */
    private Integer expectedYear;

    /**
     * 设备参数要求（如"使用小时数不超过5000小时"）
     */
    private String parameterRequirement;

    /**
     * 联系人（求购咨询的对接人）
     */
    private String contactName;

    /**
     * 联系电话（求购咨询的联系方式）
     */
    private String contactPhone;

    /**
     * 求购状态（0-待处理，1-已分配，2-已成交，3-已取消）
     */
    private Integer purchaseStatus;

    /**
     * 关联业务员表businessman_id（purchase_status=1时必填，负责跟进求购需求）
     */
    private Long businessmanId;

    /**
     * 发布时间（用户提交求购信息的时间）
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime releaseTime;

    /**
     * 记录创建时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;

    /**
     * 记录更新时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateTime;

    //映射设备类型
    @TableField(exist = false)
    private  String typeName;
    @TableField(exist = false)
    private EquipmentType equipmentType;

    @TableField(exist = false)
    private User user;

    public Long getPurchaseId() {
        return purchaseId;
    }

    public void setPurchaseId(Long purchaseId) {
        this.purchaseId = purchaseId;
    }

    public Integer getUserId() {
        return userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    public Long getTypeId() {
        return typeId;
    }

    public void setTypeId(Long typeId) {
        this.typeId = typeId;
    }

    public String getBrand() {
        return brand;
    }

    public void setBrand(String brand) {
        this.brand = brand;
    }

    public String getModel() {
        return model;
    }

    public void setModel(String model) {
        this.model = model;
    }

    public BigDecimal getExpectedPrice() {
        return expectedPrice;
    }

    public void setExpectedPrice(BigDecimal expectedPrice) {
        this.expectedPrice = expectedPrice;
    }

    public Integer getExpectedYear() {
        return expectedYear;
    }

    public void setExpectedYear(Integer expectedYear) {
        this.expectedYear = expectedYear;
    }

    public String getParameterRequirement() {
        return parameterRequirement;
    }

    public void setParameterRequirement(String parameterRequirement) {
        this.parameterRequirement = parameterRequirement;
    }

    public String getContactName() {
        return contactName;
    }

    public void setContactName(String contactName) {
        this.contactName = contactName;
    }

    public String getContactPhone() {
        return contactPhone;
    }

    public void setContactPhone(String contactPhone) {
        this.contactPhone = contactPhone;
    }

    public Integer getPurchaseStatus() {
        return purchaseStatus;
    }

    public void setPurchaseStatus(Integer purchaseStatus) {
        this.purchaseStatus = purchaseStatus;
    }

    public Long getBusinessmanId() {
        return businessmanId;
    }

    public void setBusinessmanId(Long businessmanId) {
        this.businessmanId = businessmanId;
    }

    public LocalDateTime getReleaseTime() {
        return releaseTime;
    }

    public void setReleaseTime(LocalDateTime releaseTime) {
        this.releaseTime = releaseTime;
    }

    public LocalDateTime getCreateTime() {
        return createTime;
    }

    public void setCreateTime(LocalDateTime createTime) {
        this.createTime = createTime;
    }

    public LocalDateTime getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(LocalDateTime updateTime) {
        this.updateTime = updateTime;
    }

    public EquipmentType getEquipmentType() {
        return equipmentType;
    }
    public void setEquipmentType(EquipmentType equipmentType) {
        this.equipmentType = equipmentType;
    }
    public User getUser() {
        return user;
    }
    public void setUser(User user) {
        this.user = user;
    }

    public String getTypeName() {
        return typeName;
    }

    public void setTypeName(String typeName) {
        this.typeName = typeName;
    }

    @Override
    public String toString() {
        return "PurchaseDemand{" +
        "purchaseId = " + purchaseId +
        ", userId = " + userId +
        ", typeId = " + typeId +
        ", brand = " + brand +
        ", model = " + model +
        ", expectedPrice = " + expectedPrice +
        ", expectedYear = " + expectedYear +
        ", parameterRequirement = " + parameterRequirement +
        ", contactName = " + contactName +
        ", contactPhone = " + contactPhone +
        ", purchaseStatus = " + purchaseStatus +
        ", businessmanId = " + businessmanId +
        ", releaseTime = " + releaseTime +
        ", createTime = " + createTime +
        ", updateTime = " + updateTime +
        ", typeName = " + typeName +
        ", equipmentType = " + equipmentType +
        ", user = " + user +
        "}";
    }
}
